<template>
  <div>
    <input v-model.number="num1" />
    <input v-model.number="num2" />
    <div>两个数之和为{{ result }}</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num1: 0,
      num2: 0,
      result: 0,
    }
  },
  methods: {
    sum(){
        this.result=this.num1+this.num2
    }
  },
  watch: {
    num1(){
        this.sum()
    },
    num2(){
         this.sum()
    },
  },
}
</script>

<style>

</style>